package org.creativor.rayson.transport.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.creativor.rayson.api.TransferArgument;
import org.creativor.rayson.api.TransferSocket;
import org.creativor.rayson.demo.proxy.DemoTransferArgument;
import org.creativor.rayson.transport.common.ProtocolType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>ClientStreamConnectionTest</code> contains tests for the
 * class <code>{@link ClientStreamConnection}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午2:58
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class ClientStreamConnectionTest {
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(ClientStreamConnectionTest.class);
	}

	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@After
	public void tearDown() throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Run the
	 * ClientStreamConnection(SocketAddress,TransferArgument,ConnectionManager)
	 * constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClientStreamConnection_1() throws Exception {
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		ConnectionManager connectionManager = new ConnectionManager();

		ClientStreamConnection result = new ClientStreamConnection(
				serverAddress, argument, connectionManager);

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(0L, result.getId());
		assertEquals(0, result.read());
		assertEquals((byte) 1, result.getVersion());
		assertEquals((short) 10, result.getTransfer());
		assertEquals(1304708323539L, result.getCreationTime());
		assertEquals(1304708323539L, result.getLastContactTime());
		assertEquals(false, result.isTimeOut());
	}

	/**
	 * Run the
	 * ClientStreamConnection(SocketAddress,TransferArgument,ConnectionManager)
	 * constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClientStreamConnection_2() throws Exception {
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		ConnectionManager connectionManager = new ConnectionManager();

		ClientStreamConnection result = new ClientStreamConnection(
				serverAddress, argument, connectionManager);

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(1L, result.getId());
		assertEquals(0, result.read());
		assertEquals((byte) 1, result.getVersion());
		assertEquals((short) 10, result.getTransfer());
		assertEquals(1304708323543L, result.getCreationTime());
		assertEquals(1304708323543L, result.getLastContactTime());
		assertEquals(false, result.isTimeOut());
	}

	/**
	 * Run the
	 * ClientStreamConnection(SocketAddress,TransferArgument,ConnectionManager)
	 * constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClientStreamConnection_3() throws Exception {
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		ConnectionManager connectionManager = new ConnectionManager();

		ClientStreamConnection result = new ClientStreamConnection(
				serverAddress, argument, connectionManager);

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(2L, result.getId());
		assertEquals(0, result.read());
		assertEquals((byte) 1, result.getVersion());
		assertEquals((short) 10, result.getTransfer());
		assertEquals(1304708323544L, result.getCreationTime());
		assertEquals(1304708323544L, result.getLastContactTime());
		assertEquals(false, result.isTimeOut());
	}

	/**
	 * Run the void close() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClose_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.close();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.close(ClientStreamConnection.java:157)
	}

	/**
	 * Run the void close() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClose_2() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.close();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.close(ClientStreamConnection.java:157)
	}

	/**
	 * Run the void close() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testClose_3() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.close();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.close(ClientStreamConnection.java:157)
	}

	/**
	 * Run the TransferSocket createTransferSocket() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testCreateTransferSocket_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		TransferSocket result = fixture.createTransferSocket();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.createTransferSocket(ClientStreamConnection.java:207)
		assertNotNull(result);
	}

	/**
	 * Run the TransferSocket createTransferSocket() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testCreateTransferSocket_2() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		TransferSocket result = fixture.createTransferSocket();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.createTransferSocket(ClientStreamConnection.java:207)
		assertNotNull(result);
	}

	/**
	 * Run the long getId() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetId_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		long result = fixture.getId();

		// TODO: add additional test code here
		assertEquals(9L, result);
	}

	/**
	 * Run the ProtocolType getProtocol() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetProtocol_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		ProtocolType result = fixture.getProtocol();

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals((byte) 2, result.getType());
		assertEquals("TRANSFER", result.name());
		assertEquals("TRANSFER", result.toString());
		assertEquals(2, result.ordinal());
	}

	/**
	 * Run the long getTimeoutInterval() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetTimeoutInterval_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		long result = fixture.getTimeoutInterval();

		// TODO: add additional test code here
		assertEquals(60000L, result);
	}

	/**
	 * Run the short getTransfer() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetTransfer_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		short result = fixture.getTransfer();

		// TODO: add additional test code here
		assertEquals((short) 10, result);
	}

	/**
	 * Run the byte getVersion() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetVersion_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		byte result = fixture.getVersion();

		// TODO: add additional test code here
		assertEquals((byte) 1, result);
	}

	/**
	 * Run the void init() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testInit_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.init();

		// TODO: add additional test code here
	}

	/**
	 * Run the void init() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testInit_2() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.init();

		// TODO: add additional test code here
	}

	/**
	 * Run the int read() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testRead_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		int result = fixture.read();

		// TODO: add additional test code here
		assertEquals(0, result);
	}

	/**
	 * Run the void remove() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testRemove_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.remove();

		// TODO: add additional test code here
	}

	/**
	 * Run the String toString() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testToString_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		String result = fixture.toString();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at
		// org.creativor.rayson.transport.client.ClientStreamConnection.toString(ClientStreamConnection.java:224)
		assertNotNull(result);
	}

	/**
	 * Run the void write() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testWrite_1() throws Exception {
		ClientStreamConnection fixture = new ClientStreamConnection(
				new InetSocketAddress(1), new DemoTransferArgument(""),
				new ConnectionManager());

		fixture.write();

		// TODO: add additional test code here
	}
}